home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc International / Development / TSMTEsample⁄1.1 / _SOM_ / som_SamplePartInit.cpp < prev   
Encoding:
Text File  |  1996-11-14  |  2.0 KB  |  81 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        som_SamplePartInit.cpp
  3.  
  4.     Contains:    CFM Library init routines for SamplePart
  5.  
  6.     Written by:    Steve Smith
  7.  
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12.  
  13. // -- Compiler/Preprocessor Switches --
  14.  
  15. #ifndef _COMPILERDEFS_
  16. #include "CompDefs.h"
  17. #endif
  18.  
  19. // -- OpenDoc Utilities --
  20.  
  21. #ifndef _EXCEPT_
  22. // Exceptions define several important macros (ie. CHECKENV)
  23. // which are used in the SOM method dispatch glue. If Except.h
  24. // is not included early enough, exceptions may not be thrown
  25. // correctly when returning from a SOM method with "ev" parameter set.
  26. #include <Except.h>
  27. #endif
  28.  
  29. #ifndef _USERSRCM_
  30. #include <UseRsrcM.h>
  31. #endif
  32.  
  33. #ifndef _ODMEMORY_
  34. #include <ODMemory.h>
  35. #endif
  36.  
  37. // -- MacToolbox Includes --
  38.  
  39. #ifndef __CODEFRAGMENTS__
  40. #include <CodeFragments.h>
  41. #endif
  42.  
  43. #pragma segment somSamplePartInit
  44.  
  45. //------------------------------------------------------------------------------
  46. // Prototypes
  47. //------------------------------------------------------------------------------
  48.  
  49. extern "C" pascal OSErr    SamplePartCFMInit(CFragInitBlockPtr initBlkPtr);
  50. extern "C" pascal void    SamplePartCFMTerminate();
  51.  
  52. //------------------------------------------------------------------------------
  53. // Functions
  54. //------------------------------------------------------------------------------
  55.  
  56. extern "C" pascal OSErr SamplePartCFMInit(CFragInitBlockPtr initBlkPtr)
  57. {
  58.     // We are using OpenDoc's memory mgmt calls, so we must
  59.     // initialize the interface to the memory manager.
  60.     OSErr err1 = InitODMemory();
  61.     // We must also capture the relevant information about
  62.     // our library file so that we may access our resources.
  63.     OSErr err2 = InitLibraryResources(initBlkPtr);
  64.  
  65. #if ODDebug
  66.     // DEBUG - drop into debugger if button down when lib loaded.
  67.     if ( Button() ) DebugStr("\p");
  68. #endif
  69.  
  70.     return (OSErr) (err1 != noErr) ? err1 : err2;
  71. }
  72.  
  73. extern "C" pascal void SamplePartCFMTerminate()
  74. {
  75.     // The library is being unloaded from memory, so close our
  76.     // resource fork.
  77.     CloseLibraryResources();
  78. }
  79.  
  80.  
  81.